package com.baizhi.service.impl;

import com.baizhi.dao.SingerDAO;
import com.baizhi.entity.Singer;
import com.baizhi.service.SingerService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class SingerServiceImpl implements SingerService {
    @Autowired
    private SingerDAO singerDAO;
    @Override
    public List<Singer> selectAll() {
        List<Singer> singers = singerDAO.selectAll();
        return singers;
    }

    @Override
    public PageInfo<Singer> selectPage(int page, int limit, String name) {
        PageHelper.startPage(page,limit);
        List<Singer> singers = singerDAO.selectPage(name);
        PageInfo<Singer> singerPageInfo = new PageInfo<>(singers);
        return singerPageInfo;
    }

    @Override
    public void insert(Singer singer) {
        singerDAO.insert(singer);
    }

    @Override
    public void delete(Integer id) {
        singerDAO.delete(id);
    }

    @Override
    public void deleteMany(Integer[] ids) {
        singerDAO.deleteMany(ids);
    }

    @Override
    public Singer selectOne(Integer id) {
        Singer singer = singerDAO.selectOne(id);
        return singer;
    }

    @Override
    public void update(Singer singer) {
        singerDAO.update(singer);
    }
}
